package com.yang.spring.events;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * Spring事件监听器演示应用
 */
@SpringBootApplication
public class EventDemoApplication {

    public static void main(String[] args) {
        // 启动Spring应用
        ConfigurableApplicationContext context = SpringApplication.run(EventDemoApplication.class, args);
        
        // 获取事件发布者
        CustomEventPublisher publisher = context.getBean(CustomEventPublisher.class);
        
        // 发布自定义事件
        publisher.publishCustomEvent("这是一个测试事件!");
        publisher.publishCustomEvent("这是另一个测试事件!");
        
        // 启动应用上下文（将触发ContextStartedEvent事件）
        context.start();
    }
} 